#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


typedef long long ll;
const ll N = 1000000;
pair<ll, ll> p[N];

bool cmp(const pair<ll, ll>& p1, const pair<ll, ll>& p2)
{
    if (p1.second > p2.second) return true;
    else if (p1.second == p2.second && p1.first < p2.first) return true;
    else return false;
}

int main() {
    int n, k;
    ll acid = 0, sweet = 0;
    cin >> n >> k;
    for (ll i = 0; i < n; i++) cin >> p[i].first;
    for (ll i = 0; i < n; i++) cin >> p[i].second;

    sort(p, p + n, cmp);

    for (int i = 0; i < k; i++)
    {
        acid += p[i].first;
        sweet += p[i].second;
    }

    cout << acid << " " << sweet << endl;
    return 0;
}